package com.wc.AlgoOJ_train.train1.c1.A103;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/12/26 3:50
 * 求平均成绩
 * http://43.138.190.70:8888/p/A103
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[][] arr = new int[n][m];
            double[] avgSt = new double[n];
            double[] avgOb = new double[m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    arr[i][j] = sc.nextInt();
                    avgSt[i] += arr[i][j];
                }
                avgSt[i] /= m;
            }
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    avgOb[i] += arr[j][i];
                }
                avgOb[i] /= n;
            }
            int allBig = 0;
            for (int i = 0; i < n; i++) {
                boolean flg = true;
                for (int j = 0; j < m; j++) {
                    if (arr[i][j] < avgOb[j]) {
                        flg = false;
                        break;
                    }
                }
                if (flg) {
                    allBig++;
                }
            }
            print(avgSt);
            print(avgOb);
            System.out.println(allBig);
        }
    }

    static void print(double[] avg) {
        System.out.printf("%.2f", avg[0]);
        for (int i = 1; i < avg.length; i++) {
            System.out.printf(" %.2f", avg[i]);
        }
        System.out.println();
    }
}
